<?php
function addUser(){
    $pic=uploadfile('./userpic/');
    $_POST['myFile']=$pic[0]['name'];
    $_POST['password']=md5($_POST['password']);
    if(insert('user',$_POST)){
        alertMsg('添加用户成功','addUser.php');
    }else{
   alertMsg('添加用户失败','addUser.php');
    }
    }

function delUser($id){
    if(delete('user','id='.$id)>0){
        alertMsg('删除成功','listUser.php');
    }else{
        echo '删除失败'.mysql_error();
    }
}
function editUser($id){
    $arr=$_POST;
    $arr['password']=md5($_POST['password']);
if(update("user",$arr,"id={$id}")){
    alertMsg('修改成功','listUser.php');
}else{
    alertMsg('修改失败','listUser.php');
}
}

function getAllUser($page,$pagesize){
    $offset=($page-1)*$pagesize;
    $sql="select * from user limit $offset,$pagesize";
    return fetchall($sql);
}
function getTotalUserPage(){
    return getresnum('select * from user');
}




























//wo
